package com.example.shiyansan.controller.user;

import com.example.shiyansan.entity.Order;
import com.example.shiyansan.entity.User;
import com.example.shiyansan.result.Result;
import com.example.shiyansan.service.OrderService;
import com.example.shiyansan.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.example.shiyansan.interceptor.JwtTokenInterceptor.THREAD_LOCAL;

@RestController
@RequestMapping("/user/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("/list")
    public Result<List<OrderVo>> list(){

        Long userId = (Long) THREAD_LOCAL.get();

        List<OrderVo> orderVoList =  orderService.list(userId);
        return Result.success(orderVoList);
    }
}
